<?php 


/** 
***************************************************
*欢迎使用免费版xSite企业自助建站软件！
*这是一个专业为搜索引擎营销而设计的，极稳定、极易维护的建站软件！
*官方客服：help@php.net.cn
*官方下载网址：http://www.php.net.cn/xsite/ 
***************************************************
**/




if(!defined('IN_SITETEAM')) { exit('Access Denied'); } if (!empty($_POST['dosubmit'])) { $key = $_COOKIE['key']; if (empty($key)) { message("xsite.php?action=product&operation=list&category={$category}", "缺少category参数！"); } if (!empty($_FILES['ptitle']['name'])) { if (!in_array($_FILES['ptitle']['type'], array("image/pjpeg", "image/gif", "image/jpeg", "image/png", "image/jpg"))) { message("xsite.php?action=product&operation=edit&category={$category}&key={$key}", "你所上传的图片格式不正确！请按说明上传"); } } if(!file_exists("{$user_upload_dir}/{$category}")) mkdir("{$user_upload_dir}/{$category}"); $product_info_file = $user_data_dir . "/{$category}/{$key}.txt"; $savedata = $_POST['data']; $savedata['content'] = stripslashes($savedata['content']); if ($auto_image == 1) { if(!file_exists("{$user_upload_dir}/public")) mkdir("{$user_upload_dir}/public"); $savedata['content'] = get_html_images($savedata['content'], "{$user_upload_dir}/public"); } if (isset($_POST['del_file']) && is_array($_POST['del_file']) && count($_POST['del_file'])) { if (array_key_exists('ptitle', $_POST['del_file'])) { if (file_exists($savedata['ptitle']) && preg_match("/^attachments/i", $savedata['ptitle'])) @unlink($savedata['ptitle']); $savedata['ptitle'] = ''; } } if (!empty($_FILES['ptitle']['name'])) { $fileinfo = upload_images('ptitle', "{$user_upload_dir}/{$category}", 0); if (is_array($fileinfo) && array_key_exists('name', $fileinfo) && array_key_exists('path', $fileinfo)) { if (!empty($savedata['ptitle'])) { if (file_exists($savedata['ptitle'])) { @unlink($savedata['ptitle']); } } $savedata['ptitle'] = str_replace(SITE_DIR . '/', '', "{$fileinfo['path']}{$fileinfo['name']}"); } } if (isset($_POST['product_pic_del']) && is_array($_POST['product_pic_del']) && count($_POST['product_pic_del'])) { foreach ($_POST['product_pic_del'] as $v) { if (array_key_exists($v, $savedata['product_pic'])) { @unlink($savedata['product_pic'][$v]); unset($savedata['product_pic'][$v]); } } } if(!file_exists("{$user_upload_dir}/{$category}/product")) mkdir("{$user_upload_dir}/{$category}/product"); $upload_list = upload_multiple_images('product_pic', "{$user_upload_dir}/{$category}/product"); if (is_array($upload_list) && count($upload_list)) { foreach ($upload_list as $k => $v) { $filename = "{$v['path']}{$v['name']}"; $str_rand = "pic_" . substr(md5($filename), 0, 6); $savedata['product_pic'][$str_rand] = str_replace(SITE_DIR . '/', '', $filename); } if (empty($savedata['ptitle'])) { $savedata['ptitle'] = $savedata['product_pic'][$str_rand]; } } else { $savedata['product_pic'] = array(); } save_array_file($savedata, $product_info_file); $sql = "SELECT COUNT(*) AS num FROM  `{$site_id}_product` AS p WHERE p.`key` = {$key}"; if (!empty($category)) { $sql .= " AND p.`category` = '{$category}' "; } $db->query($sql); $row = $db->fetchRow(); $row = $row['num']; $data = array(); if ($row > 0) { $data['category'] = $category; $data['name'] = $savedata['name']; $data['ptitle'] = $savedata['ptitle']; $data['pname'] = $savedata['pname']; $data['pass'] = intval($savedata['pass']); $data['status'] = intval($savedata['status']); $db->update("{$site_id}_product", $data, " `key` = {$key} "); } else { $data['key'] = $key; $data['category'] = $category; $data['name'] = $savedata['name']; $data['ptitle'] = $savedata['ptitle']; $data['pname'] = $savedata['pname']; $data['pass'] = intval($savedata['pass']); $data['status'] = intval($savedata['status']); $db->insert("{$site_id}_product", $data); } if (defined('XSITE_MU') && defined('SITE_HOST')) { $db->query("UPDATE xsite_cloud SET site_liveness = site_liveness + 1, site_action_time = '" . time() . "' WHERE site_id = '{$site_id}'"); } message("xsite.php?action=product&operation=list&category={$category}" . (!empty($page) ? "&page={$page}" : "")); } else { $default_structure_file = SITE_ROOT . "/data/default.product.structure.txt"; $default_structure = read_array_file($default_structure_file); $diy_structure_file = $user_data_dir . "/product.structure.txt"; if (file_exists($diy_structure_file)) { $diy_structure = read_array_file($diy_structure_file); $forum_structure = array_merge($default_structure, $diy_structure); } else { $forum_structure = $default_structure; } if (!empty($key) && file_exists($user_data_dir . "/{$category}/{$key}.txt")) { $product_info_file = $user_data_dir . "/{$category}/{$key}.txt"; $product_info = read_array_file($product_info_file); if (is_array($product_info) && count($product_info) > 0) foreach ($product_info as $k => $v) { if (array_key_exists($k, $forum_structure)) $forum_structure[$k]['value'] = $v; } } if (empty($key)) { $key = time(); } ob_start(); setcookie("key", $key); ob_end_flush(); foreach ($forum_structure as $k => $v) { $form[$v['formtype']][$k] = $forum_structure[$k]; } extract($form); if (isset($content['content']['name'])) { $content['content']['name'] .= '<a style="cursor:hand" onclick="create_editor(\'content\');">[开]</a><a style="cursor:hand" onclick="close_editor();">[关]</a><a target="_blank" href="http://www.webps.cn">[图]</a>'; } include SITE_ROOT . "/admin/tpl/product_edit.tpl.php"; } ?>